var Type = {}

for(var i = 0,type;type=['String','Array','Number'][i++];){
    (function(type){
        Type['is'+type] = function(obj){
            console.log(Object.prototype.toString.call(obj),'[object ' + type +']')
            return Object.prototype.toString.call(obj) ==='[object ' + type +']';
        }
    })(type)
}
console.log(Type.isArray([]))
console.log(Type.isString("str"))

//
var mult =(function(){
    var cache = {};
    var calculate = function(){//封闭函数
        var a = 1;
        for(var i=0,l=arguments.length;i<l;i++){
            a = a*arguments[i];
        }
        return a;
    }
    return function(){
        var args= Array.prototype.join.call(arguments,',');
        if(Reflect.has(cache,args)){ //等于 args in cache
            console.log('缓存了:',cache,args)
            return cache[args]
        }
        return cache[args] = calculate.apply(null,arguments)
    }
})()
console.log(mult(1,2,3))
console.log(mult(7,8,9))
console.log(mult(1,2,3))